﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Microsoft.ApplicationBlocks.Data;
using _619BJP.Models;


namespace _619BJP.Database
{
   public class branduploadDB
    {
        private string connString = System.Configuration.ConfigurationManager.ConnectionStrings["619BJP.Data.ConnectionString"].ConnectionString;

        public int uploadBrand(BrandModel brandModel)
        {
            int BrandID;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = "INSERT INTO [BR_Brand]([name],[e_name],[logo],[web_site],[description],[e_word],[brand_category],[brand_location],[created_by],[created_time],[is_deleted])VALUES(@name,@e_name,@logo,@web_site,@description,@e_word ,@brand_category,@brand_location ,@created_by ,@created_time,0);Select @@IDENTITY";
                SqlParameter[] paramsToSql = new SqlParameter[10];
                paramsToSql[0] = new SqlParameter("@name", SqlDbType.NVarChar);
                paramsToSql[0].Value = brandModel.name;
                paramsToSql[1] = new SqlParameter("@e_name", SqlDbType.NVarChar);
                paramsToSql[1].Value ="";
                paramsToSql[2] = new SqlParameter("@logo", SqlDbType.NVarChar);
                paramsToSql[2].Value = brandModel.logo;
                paramsToSql[3] = new SqlParameter("@web_site", SqlDbType.NVarChar);
                paramsToSql[3].Value = brandModel.web_site;
                paramsToSql[4] = new SqlParameter("@description", SqlDbType.Text);
                paramsToSql[4].Value = brandModel.description;

                paramsToSql[5] = new SqlParameter("@e_word", SqlDbType.NVarChar);
                paramsToSql[5].Value ="";
                paramsToSql[6] = new SqlParameter("@brand_category", SqlDbType.NVarChar);
                paramsToSql[6].Value = "";
                paramsToSql[7] = new SqlParameter("@brand_location", SqlDbType.NVarChar);
                paramsToSql[7].Value = brandModel.brand_location;

                paramsToSql[8] = new SqlParameter("@created_by", SqlDbType.NVarChar);
                paramsToSql[8].Value = "admin";
                paramsToSql[9] = new SqlParameter("@created_time", SqlDbType.DateTime);
                paramsToSql[9].Value = System.DateTime.Now;



                BrandID = Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, paramsToSql));

             
            }






            return BrandID;

        }

    }
}
